<?php
/**
 * Description: 今日好物-日期列表
 * Created by PhpStorm.
 * User: congyukun
 * Date: 2021/10/11
 * Time: 15:34
 */


use Biz\service\TodayNiceGoods\TodayNIceGoodsService;


class GetMonthListAction extends ActionPlugin
{
    public const USER_LEVEL = self::LEVEL_NOTHING;

    /**
     * 获取活动列表
     * @throws Exception
     */
    public function main()
    {
        $monthList = TodayNIceGoodsService::getMonthLists();
        if ($monthList) {
            $data['list'] = array_slice($monthList, -12, 12);
            foreach ($data['list'] as &$item) {
                if ($item['month'] == date("Y-m")) {
                    $item['is_true'] = 1;
                }
            }
        }

        return $this->setSuccess($data);
    }

}